package com.bsb.biz.controller;

import javax.annotation.Resource;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.bsb.base.model.BsbFirm;
import com.bsb.base.model.SysUser;
import com.bsb.biz.service.BsbFirmService;
import com.bsb.biz.shiro.UserUtils;

/**
 * @author :liuxb@jieshuibao.com
 * @version ：2018年5月14日 下午8:43:17
 * 类说明
 */
@Controller
public class BsbHomeController {
	
	@Resource
	private BsbFirmService BsbFirmService;
	
	@RequestMapping(value="/bsb/home",method=RequestMethod.GET)
	public String home(Model model){
		
		SysUser currentUser = UserUtils.currentUser();
		Long firmId = currentUser.getFirmId();
		if(firmId==null){
			model.addAttribute("msg", "账号异常请联系管理员！");
			return "/BsbHome/home";
		}
		BsbFirm bsbFirm = BsbFirmService.getBsbFirmByAccount(firmId.intValue());
		if(bsbFirm!=null){
			String name = bsbFirm.getName();
			model.addAttribute("firmName", name);
		}else {
			model.addAttribute("msg", "账号异常请联系管理员！");
			return "/BsbHome/home";
		}
		return "/BsbHome/home";
	}

}
